<?php

defined('SYSPATH') or die('Access error!');

class Core_Mailer_Transport_SMTP extends Core_Mailer_Transport
{

    public function build($config)
    {
        $transport = Swift_SmtpTransport::newInstance()
                ->setHost(empty($config['hostname']) ? "localhost" : (string) $config['hostname'])
                ->setUsername(empty($config['username']) ? NULL : (string) $config['username'])
                ->setPassword(empty($config['password']) ? NULL : (string) $config['password']);

        $port = empty($config['port']) ? 25 : (int) $config['port'];
        $transport->setPort($port);

        if (!empty($config['encryption']))
        {
            $transport->setEncryption($config['encryption']);
        }

        return $transport;
    }

}

